/**
 * @file   1040.cpp
 * @author Shuang Hu <hsmath@ubuntu>
 * @date   Sun May 30 18:39:14 2021
 * 
 * @brief  PAT 1040:longest symmetry string.
 * Using DP Algorithm
 * 
 */
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main(){
    string s;
    getline(cin,s);
    int n=s.length();
    vector<vector<bool>> DP;
    DP.resize(n);
    for(int i=0;i<n;i++){
	DP[i].resize(n);
    }
    for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	    DP[i][j]=false;
    int longest=1;
    for(int i=0;i<n;i++){
	DP[i][i]=true;
	if(i<n-1){
	    if(s[i]==s[i+1]){
		DP[i][i+1]=true;
		longest=2;
	    }
	}
    }
    for(int len=3;len<n;len++){
	for(int i=0;i<=n-len;i++){
	    int j=i+len-1;
	    if(DP[i+1][j-1]&&s[i]==s[j]){
		DP[i][j]=true;
		longest=len;
	    }
	}
    }
    cout<<longest<<endl;
}
